<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">    

        <h:panelGroup rendered="true" >
            <h:form>
                <p:panel id="reportPrint" styleClass="noBorder summeryBorder" header="All Cashier Summary">
                    <f:facet name="header">

                        <p:commandButton id="btnRefresh" ajax="false" value="Refresh" styleClass="noPrintButton" style="float: right;" actionListener="#{cashierReportController.calCashierData()}" />  
                        <p:defaultCommand target="btnRefresh"/>
                        
                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="reportPrint" />
                        </p:commandButton>  
                        
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" >
                            <pe:exporter type="xlsx" target="tbl" fileName="Cashier_Report" subTable="true"  />
                        </p:commandButton>  

                        <h:outputLabel value="#{sessionController.loggedUser.institution.name}"/> <br/>

                        <h:panelGrid columns="4" style="min-width: 100%;" styleClass="noPrintButton">
                            <h:outputLabel value="From Date" />
                            <p:calendar id="frmDate" value="#{cashierReportController.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss"  >
                            </p:calendar>

                            <h:outputLabel value="To Date"/>
                            <p:calendar id="toDate" value="#{cashierReportController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss">
                            </p:calendar>

                        </h:panelGrid>
                        <h:panelGrid columns="7" styleClass="printBlock" style="min-width: 100%;">

                            <h:outputLabel value="Cashier-Wice Session Report"/>
                             <p:spacer width="20" height="0"/>
                            <h:outputLabel value="From" />
                            <h:outputLabel  value="#{cashierReportController.fromDate}" >
                                <f:convertDateTime pattern="dd MM yy hh:mm a"/>
                            </h:outputLabel>
                            <p:spacer width="10" height="0"/>
                            <h:outputLabel value="To"/>
                            <h:outputLabel  value="#{cashierReportController.toDate}" style="float: right" >
                                <f:convertDateTime pattern="dd MM yy hh:mm a"/>
                            </h:outputLabel>
                        </h:panelGrid>

                    </f:facet>

                    <p:dataTable id="tbl" value="#{cashierReportController.webUserBillsTotals}" var="csh">

                        <p:columnGroup type="header">
                            <p:row>
                                <p:column headerText="Description"/>
                                <p:column headerText="Cash"/>
                                <p:column headerText="Credit"/>
                                <p:column headerText="C Card"/>
                                <p:column headerText="Cheque"/>
                                <p:column headerText="Slip"/>
                            </p:row>
                        </p:columnGroup>

                        <p:subTable value="#{csh.billsTotals}" var="dt">

                            <f:facet name="header">
                                <h:outputLabel value="#{csh.webUser.code}-"/>
                                <h:outputLabel value="#{csh.webUser.webUserPerson.name}"/>
                            </f:facet>
                            
                            <p:column>
                                <h:outputLabel value="#{dt.name}"></h:outputLabel>
                            </p:column>
                            
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dt.cash}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>
                            
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dt.credit}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>
                            
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dt.card}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>
                            
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dt.cheque}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>
                            
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dt.slip}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                                
                            </p:column>
                        </p:subTable>

                        <p:columnGroup type="footer">
                            <p:row>

                                <p:column footerText="Total">

                                </p:column>

                                <p:column footerText="#{cashierReportController.finalCashTot}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{cashierReportController.finalCashTot}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{cashierReportController.finalCreditTot}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{cashierReportController.finalCreditTot}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{cashierReportController.finalCardTot}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{cashierReportController.finalCardTot}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{cashierReportController.finalChequeTot}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{cashierReportController.finalChequeTot}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{cashierReportController.finalSlipTot}" style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{cashierReportController.finalSlipTot}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                            </p:row>
                        </p:columnGroup>
                    </p:dataTable>


                </p:panel>  



            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
